package com.jhd.fuzhou.view.quantitative;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.jhd.fuzhou.view.daily.DocumentListActivity;
import com.jhd.fuzhou.view.login.BaseActivity;
import com.jhd.fuzhou.R;
import com.jhd.fuzhou.vo.SupervisedUnitVo;

import net.zigin.commons.util.StringUtil;

import butterknife.BindView;
import butterknife.OnClick;

public class QuantitativeCompanyDetailActivity extends BaseActivity {
    private SupervisedUnitVo supervisedUnitVo;
    @BindView(R.id.tv_unitName)
    TextView tv_unitName;//被监督单位
    @BindView(R.id.tv_creditCode)TextView tv_creditCode;//社会信用代码
    @BindView(R.id.tv_status)TextView tv_status;//经验状态
    @BindView(R.id.tv_superviseOffice)TextView tv_superviseOffice;//监督机构
    @BindView(R.id.tv_superviseSector)TextView tv_superviseSector;//监督部门
    @BindView(R.id.tv_legalRepresentative)TextView tv_legalRepresentative;//法人代表
    @BindView(R.id.tv_gender)TextView tv_gender;//性别
    @BindView(R.id.tv_nation)TextView tv_nation;//民族
    @BindView(R.id.tv_contactNumber)TextView tv_contactNumber;//单位电话
    @BindView(R.id.tv_registerAddress)TextView tv_registerAddress;//注册地址
    @BindView(R.id.btn_add_report)
    Button btn_add_report;//添加报告
    @BindView(R.id.btn_editing_unit)Button btn_editing_unit;//编辑单位
    @BindView(R.id.btn_supervision_record)Button btn_supervision_record;//评级记录
    private String data;
    private Context context= this;
    private Gson gson=new Gson();
    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.activity_company_detail);
    }

    @Override
    protected void processLogic() {
        onBack();
        data=getIntent().getStringExtra("data");
        btn_supervision_record.setText("评级记录");
        if(StringUtil.isNullOrEmpty(data)==false){
            supervisedUnitVo = JSON.parseObject(data, SupervisedUnitVo.class);
            tv_unitName.setText(supervisedUnitVo.getUnitName());
            tv_creditCode.setText(supervisedUnitVo.getCreditCode());
            if(supervisedUnitVo.getBusinessStatus().equals("0")){
                tv_status.setText("关闭");
            }else if(supervisedUnitVo.getBusinessStatus().equals("1")){
                tv_status.setText("正常");
            }else if(supervisedUnitVo.getBusinessStatus().equals("2")){
                tv_status.setText("暂停");
            }else{
                tv_status.setText("未知");
            }
            tv_superviseOffice.setText(supervisedUnitVo.getSuperviseOffice());
            tv_superviseSector.setText(supervisedUnitVo.getSuperviseSector());
            tv_legalRepresentative.setText(supervisedUnitVo.getLegalRepresentative());
            tv_gender.setText(supervisedUnitVo.getGender());
            tv_nation.setText(supervisedUnitVo.getNation());
            tv_contactNumber.setText(supervisedUnitVo.getContactNumber());
            tv_registerAddress.setText(supervisedUnitVo.getRegisterAddress());
        }
    }
    @OnClick({R.id.btn_add_report,R.id.btn_editing_unit,R.id.btn_supervision_record})
    public void onClick(View v){
        switch (v.getId()){
            case R.id.btn_add_report:
                Intent intent=new Intent(context, QuantitativeStepOneActivity.class);
                intent.putExtra("data", data);
                startActivity(intent);
                finish();
                break;
            case R.id.btn_editing_unit:

                break;
            case R.id.btn_supervision_record:
                Intent intent3=new Intent(context, DocumentListActivity.class);
                intent3.putExtra("type","4");
                intent3.putExtra("unitName",supervisedUnitVo.getUnitName());
                intent3.putExtra("supervisionUnit",gson.toJson(supervisedUnitVo));
                startActivity(intent3);
                break;
        }
    }
}